<?php

	// TITLE: BREMS DBIO
	// FILE: model/dbio.php
	// AUTHOR: AUTOGEN
	// DATE: 10/29/2014

	class dbio {

        // ATTRIBUTES /////////////////////////////////////////////////////////////////////////////

        protected $con;

        // CONSTRUCTOR ////////////////////////////////////////////////////////////////////////////

        public function __construct() {}


        // METHODS ////////////////////////////////////////////////////////////////////////////////

        private function open() {
            global $con;
 
            $hostname = '127.0.0.1';
            $username = 'root';
            $password = 'abc123';
            $database = 'brems';
            $infobase = '';
 
            $con = mysqlii_connect($hostname, $username, $password, $database);
        }// END

        private function close() {
            global $con;
            mysqlii_close($con);
        }// END

		// address // --------------------

		public function createAddress($address) {
			global $con;
			$fieldsString = csvObject($address);
			$valuesString = csvString($address);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readAddress($id) {
			global $con;
			$sql = 'SELECT * FROM address WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$address = new Address();
				$address->setId(result[0]);
				$address->setStreet_1(result[1]);
				$address->setStreet_2(result[2]);
				$address->setCity_id(result[3]);
				$address->setState_id(result[4]);
				$address->setZip(result[5]);
			} else {
				$address = false
			}
			return $address;
		}// end function

		public function updateAddress($address) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO address VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteAddress($id) {
			global $con;
			$sql = 'DELETE FROM address WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listAddress() {
			global $con;
			$sql = 'SELECT * FROM address';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$addresss = array();
				while($result = mysqli_fetch_array($results)) {
					$address = new Address();
					$address->setId(result[0]);
					$address->setStreet_1(result[1]);
					$address->setStreet_2(result[2]);
					$address->setCity(readCity(result[3]));
					$address->setState(readState(result[4]));
					$address->setZip(result[5]);
					$addresss[] = $address;
				}// end while
			} else {
				$address = false
			}
			return $address;
		}// end function

		// building // --------------------

		public function createBuilding($building) {
			global $con;
			$fieldsString = csvObject($building);
			$valuesString = csvString($building);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readBuilding($id) {
			global $con;
			$sql = 'SELECT * FROM building WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$building = new Building();
				$building->setId(result[0]);
				$building->setTitle(result[1]);
				$building->setAddress_id(result[2]);
				$building->setFacility_id(result[3]);
			} else {
				$building = false
			}
			return $building;
		}// end function

		public function updateBuilding($building) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO building VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteBuilding($id) {
			global $con;
			$sql = 'DELETE FROM building WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listBuilding() {
			global $con;
			$sql = 'SELECT * FROM building';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$buildings = array();
				while($result = mysqli_fetch_array($results)) {
					$building = new Building();
					$building->setId(result[0]);
					$building->setTitle(result[1]);
					$building->setAddress(readAddress(result[2]));
					$building->setFacility(readFacility(result[3]));
					$buildings[] = $building;
				}// end while
			} else {
				$building = false
			}
			return $building;
		}// end function

		// business // --------------------

		public function createBusiness($business) {
			global $con;
			$fieldsString = csvObject($business);
			$valuesString = csvString($business);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readBusiness($id) {
			global $con;
			$sql = 'SELECT * FROM business WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$business = new Business();
				$business->setId(result[0]);
				$business->setTitle(result[1]);
				$business->setDescription(result[2]);
				$business->setAddress_id(result[3]);
				$business->setPhone_id(result[4]);
				$business->setContact_id(result[5]);
			} else {
				$business = false
			}
			return $business;
		}// end function

		public function updateBusiness($business) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO business VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteBusiness($id) {
			global $con;
			$sql = 'DELETE FROM business WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listBusiness() {
			global $con;
			$sql = 'SELECT * FROM business';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$businesss = array();
				while($result = mysqli_fetch_array($results)) {
					$business = new Business();
					$business->setId(result[0]);
					$business->setTitle(result[1]);
					$business->setDescription(result[2]);
					$business->setAddress(readAddress(result[3]));
					$business->setPhone(readPhone(result[4]));
					$business->setContact(readContact(result[5]));
					$businesss[] = $business;
				}// end while
			} else {
				$business = false
			}
			return $business;
		}// end function

		// city // --------------------

		public function createCity($city) {
			global $con;
			$fieldsString = csvObject($city);
			$valuesString = csvString($city);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readCity($id) {
			global $con;
			$sql = 'SELECT * FROM city WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$city = new City();
				$city->setId(result[0]);
				$city->setTitle(result[1]);
				$city->setState_id(result[2]);
			} else {
				$city = false
			}
			return $city;
		}// end function

		public function updateCity($city) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO city VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteCity($id) {
			global $con;
			$sql = 'DELETE FROM city WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listCity() {
			global $con;
			$sql = 'SELECT * FROM city';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$citys = array();
				while($result = mysqli_fetch_array($results)) {
					$city = new City();
					$city->setId(result[0]);
					$city->setTitle(result[1]);
					$city->setState(readState(result[2]));
					$citys[] = $city;
				}// end while
			} else {
				$city = false
			}
			return $city;
		}// end function

		// contact // --------------------

		public function createContact($contact) {
			global $con;
			$fieldsString = csvObject($contact);
			$valuesString = csvString($contact);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readContact($id) {
			global $con;
			$sql = 'SELECT * FROM contact WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$contact = new Contact();
				$contact->setId(result[0]);
				$contact->setTitle(result[1]);
				$contact->setDescription(result[2]);
				$contact->setPhone_id(result[3]);
				$contact->setAddress_id(result[4]);
				$contact->setPerson_id(result[5]);
			} else {
				$contact = false
			}
			return $contact;
		}// end function

		public function updateContact($contact) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO contact VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteContact($id) {
			global $con;
			$sql = 'DELETE FROM contact WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listContact() {
			global $con;
			$sql = 'SELECT * FROM contact';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$contacts = array();
				while($result = mysqli_fetch_array($results)) {
					$contact = new Contact();
					$contact->setId(result[0]);
					$contact->setTitle(result[1]);
					$contact->setDescription(result[2]);
					$contact->setPhone(readPhone(result[3]));
					$contact->setAddress(readAddress(result[4]));
					$contact->setPerson(readPerson(result[5]));
					$contacts[] = $contact;
				}// end while
			} else {
				$contact = false
			}
			return $contact;
		}// end function

		// day // --------------------

		public function createDay($day) {
			global $con;
			$fieldsString = csvObject($day);
			$valuesString = csvString($day);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readDay($id) {
			global $con;
			$sql = 'SELECT * FROM day WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$day = new Day();
				$day->setId(result[0]);
				$day->setTitle(result[1]);
			} else {
				$day = false
			}
			return $day;
		}// end function

		public function updateDay($day) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO day VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteDay($id) {
			global $con;
			$sql = 'DELETE FROM day WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listDay() {
			global $con;
			$sql = 'SELECT * FROM day';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$days = array();
				while($result = mysqli_fetch_array($results)) {
					$day = new Day();
					$day->setId(result[0]);
					$day->setTitle(result[1]);
					$days[] = $day;
				}// end while
			} else {
				$day = false
			}
			return $day;
		}// end function

		// event // --------------------

		public function createEvent($event) {
			global $con;
			$fieldsString = csvObject($event);
			$valuesString = csvString($event);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readEvent($id) {
			global $con;
			$sql = 'SELECT * FROM event WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$event = new Event();
				$event->setId(result[0]);
				$event->setTitle(result[1]);
			} else {
				$event = false
			}
			return $event;
		}// end function

		public function updateEvent($event) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO event VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteEvent($id) {
			global $con;
			$sql = 'DELETE FROM event WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listEvent() {
			global $con;
			$sql = 'SELECT * FROM event';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$events = array();
				while($result = mysqli_fetch_array($results)) {
					$event = new Event();
					$event->setId(result[0]);
					$event->setTitle(result[1]);
					$events[] = $event;
				}// end while
			} else {
				$event = false
			}
			return $event;
		}// end function

		// event_day // --------------------

		public function createEvent_day($event_day) {
			global $con;
			$fieldsString = csvObject($event_day);
			$valuesString = csvString($event_day);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readEvent_day($id) {
			global $con;
			$sql = 'SELECT * FROM event_day WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$event_day = new Event_day();
				$event_day->setId(result[0]);
				$event_day->setEvent_id(result[1]);
				$event_day->setNumber(result[2]);
				$event_day->setDate(result[3]);
				$event_day->setDay_id(result[4]);
				$event_day->setMonth_id(result[5]);
			} else {
				$event_day = false
			}
			return $event_day;
		}// end function

		public function updateEvent_day($event_day) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO event_day VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteEvent_day($id) {
			global $con;
			$sql = 'DELETE FROM event_day WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listEvent_day() {
			global $con;
			$sql = 'SELECT * FROM event_day';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$event_days = array();
				while($result = mysqli_fetch_array($results)) {
					$event_day = new Event_day();
					$event_day->setId(result[0]);
					$event_day->setEvent(readEvent(result[1]));
					$event_day->setNumber(result[2]);
					$event_day->setDate(result[3]);
					$event_day->setDay(readDay(result[4]));
					$event_day->setMonth(readMonth(result[5]));
					$event_days[] = $event_day;
				}// end while
			} else {
				$event_day = false
			}
			return $event_day;
		}// end function

		// facility // --------------------

		public function createFacility($facility) {
			global $con;
			$fieldsString = csvObject($facility);
			$valuesString = csvString($facility);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readFacility($id) {
			global $con;
			$sql = 'SELECT * FROM facility WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$facility = new Facility();
				$facility->setId(result[0]);
				$facility->setTitle(result[1]);
				$facility->setDescription(result[2]);
				$facility->setAddress_id(result[3]);
			} else {
				$facility = false
			}
			return $facility;
		}// end function

		public function updateFacility($facility) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO facility VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteFacility($id) {
			global $con;
			$sql = 'DELETE FROM facility WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listFacility() {
			global $con;
			$sql = 'SELECT * FROM facility';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$facilitys = array();
				while($result = mysqli_fetch_array($results)) {
					$facility = new Facility();
					$facility->setId(result[0]);
					$facility->setTitle(result[1]);
					$facility->setDescription(result[2]);
					$facility->setAddress(readAddress(result[3]));
					$facilitys[] = $facility;
				}// end while
			} else {
				$facility = false
			}
			return $facility;
		}// end function

		// floor // --------------------

		public function createFloor($floor) {
			global $con;
			$fieldsString = csvObject($floor);
			$valuesString = csvString($floor);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readFloor($id) {
			global $con;
			$sql = 'SELECT * FROM floor WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$floor = new Floor();
				$floor->setId(result[0]);
				$floor->setTitle(result[1]);
				$floor->setBuilding_id(result[2]);
			} else {
				$floor = false
			}
			return $floor;
		}// end function

		public function updateFloor($floor) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO floor VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteFloor($id) {
			global $con;
			$sql = 'DELETE FROM floor WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listFloor() {
			global $con;
			$sql = 'SELECT * FROM floor';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$floors = array();
				while($result = mysqli_fetch_array($results)) {
					$floor = new Floor();
					$floor->setId(result[0]);
					$floor->setTitle(result[1]);
					$floor->setBuilding(readBuilding(result[2]));
					$floors[] = $floor;
				}// end while
			} else {
				$floor = false
			}
			return $floor;
		}// end function

		// guest // --------------------

		public function createGuest($guest) {
			global $con;
			$fieldsString = csvObject($guest);
			$valuesString = csvString($guest);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readGuest($id) {
			global $con;
			$sql = 'SELECT * FROM guest WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$guest = new Guest();
				$guest->setId(result[0]);
				$guest->setInvitation_id(result[1]);
				$guest->setPerson_id(result[2]);
				$guest->setStatus_id(result[3]);
				$guest->setGuestList_id(result[4]);
			} else {
				$guest = false
			}
			return $guest;
		}// end function

		public function updateGuest($guest) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO guest VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteGuest($id) {
			global $con;
			$sql = 'DELETE FROM guest WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listGuest() {
			global $con;
			$sql = 'SELECT * FROM guest';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$guests = array();
				while($result = mysqli_fetch_array($results)) {
					$guest = new Guest();
					$guest->setId(result[0]);
					$guest->setInvitation(readInvitation(result[1]));
					$guest->setPerson(readPerson(result[2]));
					$guest->setStatus(readStatus(result[3]));
					$guest->setGuestList(readGuestList(result[4]));
					$guests[] = $guest;
				}// end while
			} else {
				$guest = false
			}
			return $guest;
		}// end function

		// guest_list // --------------------

		public function createGuest_list($guest_list) {
			global $con;
			$fieldsString = csvObject($guest_list);
			$valuesString = csvString($guest_list);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readGuest_list($id) {
			global $con;
			$sql = 'SELECT * FROM guest_list WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$guest_list = new Guest_list();
				$guest_list->setId(result[0]);
				$guest_list->setTitle(result[1]);
				$guest_list->setEvent_id(result[2]);
				$guest_list->setSubEvent_id(result[3]);
			} else {
				$guest_list = false
			}
			return $guest_list;
		}// end function

		public function updateGuest_list($guest_list) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO guest_list VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteGuest_list($id) {
			global $con;
			$sql = 'DELETE FROM guest_list WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listGuest_list() {
			global $con;
			$sql = 'SELECT * FROM guest_list';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$guest_lists = array();
				while($result = mysqli_fetch_array($results)) {
					$guest_list = new Guest_list();
					$guest_list->setId(result[0]);
					$guest_list->setTitle(result[1]);
					$guest_list->setEvent(readEvent(result[2]));
					$guest_list->setSubEvent(readSubEvent(result[3]));
					$guest_lists[] = $guest_list;
				}// end while
			} else {
				$guest_list = false
			}
			return $guest_list;
		}// end function

		// invitation // --------------------

		public function createInvitation($invitation) {
			global $con;
			$fieldsString = csvObject($invitation);
			$valuesString = csvString($invitation);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readInvitation($id) {
			global $con;
			$sql = 'SELECT * FROM invitation WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$invitation = new Invitation();
				$invitation->setId(result[0]);
				$invitation->setAddress_id(result[1]);
				$invitation->setEvent_code(result[2]);
				$invitation->setInvite_code(result[3]);
				$invitation->setStatus_id(result[4]);
				$invitation->setGuestList_id(result[5]);
			} else {
				$invitation = false
			}
			return $invitation;
		}// end function

		public function updateInvitation($invitation) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO invitation VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteInvitation($id) {
			global $con;
			$sql = 'DELETE FROM invitation WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listInvitation() {
			global $con;
			$sql = 'SELECT * FROM invitation';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$invitations = array();
				while($result = mysqli_fetch_array($results)) {
					$invitation = new Invitation();
					$invitation->setId(result[0]);
					$invitation->setAddress(readAddress(result[1]));
					$invitation->setEvent_code(result[2]);
					$invitation->setInvite_code(result[3]);
					$invitation->setStatus(readStatus(result[4]));
					$invitation->setGuestList(readGuestList(result[5]));
					$invitations[] = $invitation;
				}// end while
			} else {
				$invitation = false
			}
			return $invitation;
		}// end function

		// invite_status // --------------------

		public function createInvite_status($invite_status) {
			global $con;
			$fieldsString = csvObject($invite_status);
			$valuesString = csvString($invite_status);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readInvite_status($id) {
			global $con;
			$sql = 'SELECT * FROM invite_status WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$invite_status = new Invite_status();
				$invite_status->setId(result[0]);
				$invite_status->setTitle(result[1]);
				$invite_status->setSymbol(result[2]);
			} else {
				$invite_status = false
			}
			return $invite_status;
		}// end function

		public function updateInvite_status($invite_status) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO invite_status VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteInvite_status($id) {
			global $con;
			$sql = 'DELETE FROM invite_status WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listInvite_status() {
			global $con;
			$sql = 'SELECT * FROM invite_status';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$invite_statuss = array();
				while($result = mysqli_fetch_array($results)) {
					$invite_status = new Invite_status();
					$invite_status->setId(result[0]);
					$invite_status->setTitle(result[1]);
					$invite_status->setSymbol(result[2]);
					$invite_statuss[] = $invite_status;
				}// end while
			} else {
				$invite_status = false
			}
			return $invite_status;
		}// end function

		// location // --------------------

		public function createLocation($location) {
			global $con;
			$fieldsString = csvObject($location);
			$valuesString = csvString($location);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readLocation($id) {
			global $con;
			$sql = 'SELECT * FROM location WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$location = new Location();
				$location->setId(result[0]);
				$location->setTitle(result[1]);
				$location->setFacility_id(result[2]);
				$location->setBuilding_id(result[3]);
				$location->setFloor_id(result[4]);
				$location->setRoom_id(result[5]);
				$location->setCost(result[6]);
			} else {
				$location = false
			}
			return $location;
		}// end function

		public function updateLocation($location) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO location VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteLocation($id) {
			global $con;
			$sql = 'DELETE FROM location WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listLocation() {
			global $con;
			$sql = 'SELECT * FROM location';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$locations = array();
				while($result = mysqli_fetch_array($results)) {
					$location = new Location();
					$location->setId(result[0]);
					$location->setTitle(result[1]);
					$location->setFacility(readFacility(result[2]));
					$location->setBuilding(readBuilding(result[3]));
					$location->setFloor(readFloor(result[4]));
					$location->setRoom(readRoom(result[5]));
					$location->setCost(result[6]);
					$locations[] = $location;
				}// end while
			} else {
				$location = false
			}
			return $location;
		}// end function

		// month // --------------------

		public function createMonth($month) {
			global $con;
			$fieldsString = csvObject($month);
			$valuesString = csvString($month);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readMonth($id) {
			global $con;
			$sql = 'SELECT * FROM month WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$month = new Month();
				$month->setId(result[0]);
				$month->setTitle(result[1]);
				$month->setDay_count(result[2]);
			} else {
				$month = false
			}
			return $month;
		}// end function

		public function updateMonth($month) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO month VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteMonth($id) {
			global $con;
			$sql = 'DELETE FROM month WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listMonth() {
			global $con;
			$sql = 'SELECT * FROM month';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$months = array();
				while($result = mysqli_fetch_array($results)) {
					$month = new Month();
					$month->setId(result[0]);
					$month->setTitle(result[1]);
					$month->setDay_count(result[2]);
					$months[] = $month;
				}// end while
			} else {
				$month = false
			}
			return $month;
		}// end function

		// person // --------------------

		public function createPerson($person) {
			global $con;
			$fieldsString = csvObject($person);
			$valuesString = csvString($person);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readPerson($id) {
			global $con;
			$sql = 'SELECT * FROM person WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$person = new Person();
				$person->setId(result[0]);
				$person->setTitle_id(result[1]);
				$person->setFirst_name(result[2]);
				$person->setMiddle_name(result[3]);
				$person->setLast_name(result[4]);
				$person->setSuffix_id(result[5]);
				$person->setAddress_id(result[6]);
			} else {
				$person = false
			}
			return $person;
		}// end function

		public function updatePerson($person) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO person VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deletePerson($id) {
			global $con;
			$sql = 'DELETE FROM person WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listPerson() {
			global $con;
			$sql = 'SELECT * FROM person';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$persons = array();
				while($result = mysqli_fetch_array($results)) {
					$person = new Person();
					$person->setId(result[0]);
					$person->setTitle(readTitle(result[1]));
					$person->setFirst_name(result[2]);
					$person->setMiddle_name(result[3]);
					$person->setLast_name(result[4]);
					$person->setSuffix(readSuffix(result[5]));
					$person->setAddress(readAddress(result[6]));
					$persons[] = $person;
				}// end while
			} else {
				$person = false
			}
			return $person;
		}// end function

		// person_suffix // --------------------

		public function createPerson_suffix($person_suffix) {
			global $con;
			$fieldsString = csvObject($person_suffix);
			$valuesString = csvString($person_suffix);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readPerson_suffix($id) {
			global $con;
			$sql = 'SELECT * FROM person_suffix WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$person_suffix = new Person_suffix();
				$person_suffix->setId(result[0]);
				$person_suffix->setTitle(result[1]);
			} else {
				$person_suffix = false
			}
			return $person_suffix;
		}// end function

		public function updatePerson_suffix($person_suffix) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO person_suffix VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deletePerson_suffix($id) {
			global $con;
			$sql = 'DELETE FROM person_suffix WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listPerson_suffix() {
			global $con;
			$sql = 'SELECT * FROM person_suffix';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$person_suffixs = array();
				while($result = mysqli_fetch_array($results)) {
					$person_suffix = new Person_suffix();
					$person_suffix->setId(result[0]);
					$person_suffix->setTitle(result[1]);
					$person_suffixs[] = $person_suffix;
				}// end while
			} else {
				$person_suffix = false
			}
			return $person_suffix;
		}// end function

		// person_title // --------------------

		public function createPerson_title($person_title) {
			global $con;
			$fieldsString = csvObject($person_title);
			$valuesString = csvString($person_title);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readPerson_title($id) {
			global $con;
			$sql = 'SELECT * FROM person_title WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$person_title = new Person_title();
				$person_title->setId(result[0]);
				$person_title->setTitle(result[1]);
				$person_title->setShort(result[2]);
			} else {
				$person_title = false
			}
			return $person_title;
		}// end function

		public function updatePerson_title($person_title) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO person_title VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deletePerson_title($id) {
			global $con;
			$sql = 'DELETE FROM person_title WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listPerson_title() {
			global $con;
			$sql = 'SELECT * FROM person_title';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$person_titles = array();
				while($result = mysqli_fetch_array($results)) {
					$person_title = new Person_title();
					$person_title->setId(result[0]);
					$person_title->setTitle(result[1]);
					$person_title->setShort(result[2]);
					$person_titles[] = $person_title;
				}// end while
			} else {
				$person_title = false
			}
			return $person_title;
		}// end function

		// phone // --------------------

		public function createPhone($phone) {
			global $con;
			$fieldsString = csvObject($phone);
			$valuesString = csvString($phone);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readPhone($id) {
			global $con;
			$sql = 'SELECT * FROM phone WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$phone = new Phone();
				$phone->setId(result[0]);
				$phone->setArea_code(result[1]);
				$phone->setNumber(result[2]);
				$phone->setExt(result[3]);
				$phone->setType_id(result[4]);
			} else {
				$phone = false
			}
			return $phone;
		}// end function

		public function updatePhone($phone) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO phone VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deletePhone($id) {
			global $con;
			$sql = 'DELETE FROM phone WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listPhone() {
			global $con;
			$sql = 'SELECT * FROM phone';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$phones = array();
				while($result = mysqli_fetch_array($results)) {
					$phone = new Phone();
					$phone->setId(result[0]);
					$phone->setArea_code(result[1]);
					$phone->setNumber(result[2]);
					$phone->setExt(result[3]);
					$phone->setType(readType(result[4]));
					$phones[] = $phone;
				}// end while
			} else {
				$phone = false
			}
			return $phone;
		}// end function

		// phone_type // --------------------

		public function createPhone_type($phone_type) {
			global $con;
			$fieldsString = csvObject($phone_type);
			$valuesString = csvString($phone_type);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readPhone_type($id) {
			global $con;
			$sql = 'SELECT * FROM phone_type WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$phone_type = new Phone_type();
				$phone_type->setId(result[0]);
				$phone_type->setTitle(result[1]);
				$phone_type->setDescription(result[2]);
			} else {
				$phone_type = false
			}
			return $phone_type;
		}// end function

		public function updatePhone_type($phone_type) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO phone_type VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deletePhone_type($id) {
			global $con;
			$sql = 'DELETE FROM phone_type WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listPhone_type() {
			global $con;
			$sql = 'SELECT * FROM phone_type';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$phone_types = array();
				while($result = mysqli_fetch_array($results)) {
					$phone_type = new Phone_type();
					$phone_type->setId(result[0]);
					$phone_type->setTitle(result[1]);
					$phone_type->setDescription(result[2]);
					$phone_types[] = $phone_type;
				}// end while
			} else {
				$phone_type = false
			}
			return $phone_type;
		}// end function

		// poll // --------------------

		public function createPoll($poll) {
			global $con;
			$fieldsString = csvObject($poll);
			$valuesString = csvString($poll);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readPoll($id) {
			global $con;
			$sql = 'SELECT * FROM poll WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$poll = new Poll();
				$poll->setId(result[0]);
				$poll->setTitle(result[1]);
				$poll->setDescription(result[2]);
				$poll->setEvent_id(result[3]);
				$poll->setSubEvent_id(result[4]);
				$poll->setRestriction_id(result[5]);
			} else {
				$poll = false
			}
			return $poll;
		}// end function

		public function updatePoll($poll) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO poll VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deletePoll($id) {
			global $con;
			$sql = 'DELETE FROM poll WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listPoll() {
			global $con;
			$sql = 'SELECT * FROM poll';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$polls = array();
				while($result = mysqli_fetch_array($results)) {
					$poll = new Poll();
					$poll->setId(result[0]);
					$poll->setTitle(result[1]);
					$poll->setDescription(result[2]);
					$poll->setEvent(readEvent(result[3]));
					$poll->setSubEvent(readSubEvent(result[4]));
					$poll->setRestriction(readRestriction(result[5]));
					$polls[] = $poll;
				}// end while
			} else {
				$poll = false
			}
			return $poll;
		}// end function

		// room // --------------------

		public function createRoom($room) {
			global $con;
			$fieldsString = csvObject($room);
			$valuesString = csvString($room);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readRoom($id) {
			global $con;
			$sql = 'SELECT * FROM room WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$room = new Room();
				$room->setId(result[0]);
				$room->setTitle(result[1]);
				$room->setNumber(result[2]);
				$room->setFloor_id(result[3]);
			} else {
				$room = false
			}
			return $room;
		}// end function

		public function updateRoom($room) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO room VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteRoom($id) {
			global $con;
			$sql = 'DELETE FROM room WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listRoom() {
			global $con;
			$sql = 'SELECT * FROM room';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$rooms = array();
				while($result = mysqli_fetch_array($results)) {
					$room = new Room();
					$room->setId(result[0]);
					$room->setTitle(result[1]);
					$room->setNumber(result[2]);
					$room->setFloor(readFloor(result[3]));
					$rooms[] = $room;
				}// end while
			} else {
				$room = false
			}
			return $room;
		}// end function

		// service // --------------------

		public function createService($service) {
			global $con;
			$fieldsString = csvObject($service);
			$valuesString = csvString($service);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readService($id) {
			global $con;
			$sql = 'SELECT * FROM service WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$service = new Service();
				$service->setId(result[0]);
				$service->setTitle(result[1]);
				$service->setDescription(result[2]);
				$service->setVendor_id(result[3]);
				$service->setSub_event_id(result[4]);
			} else {
				$service = false
			}
			return $service;
		}// end function

		public function updateService($service) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO service VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteService($id) {
			global $con;
			$sql = 'DELETE FROM service WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listService() {
			global $con;
			$sql = 'SELECT * FROM service';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$services = array();
				while($result = mysqli_fetch_array($results)) {
					$service = new Service();
					$service->setId(result[0]);
					$service->setTitle(result[1]);
					$service->setDescription(result[2]);
					$service->setVendor(readVendor(result[3]));
					$service->setSub_event(readSub_event(result[4]));
					$services[] = $service;
				}// end while
			} else {
				$service = false
			}
			return $service;
		}// end function

		// state // --------------------

		public function createState($state) {
			global $con;
			$fieldsString = csvObject($state);
			$valuesString = csvString($state);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readState($id) {
			global $con;
			$sql = 'SELECT * FROM state WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$state = new State();
				$state->setId(result[0]);
				$state->setTitle(result[1]);
				$state->setShort(result[2]);
			} else {
				$state = false
			}
			return $state;
		}// end function

		public function updateState($state) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO state VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteState($id) {
			global $con;
			$sql = 'DELETE FROM state WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listState() {
			global $con;
			$sql = 'SELECT * FROM state';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$states = array();
				while($result = mysqli_fetch_array($results)) {
					$state = new State();
					$state->setId(result[0]);
					$state->setTitle(result[1]);
					$state->setShort(result[2]);
					$states[] = $state;
				}// end while
			} else {
				$state = false
			}
			return $state;
		}// end function

		// sub_event // --------------------

		public function createSub_event($sub_event) {
			global $con;
			$fieldsString = csvObject($sub_event);
			$valuesString = csvString($sub_event);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readSub_event($id) {
			global $con;
			$sql = 'SELECT * FROM sub_event WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$sub_event = new Sub_event();
				$sub_event->setId(result[0]);
				$sub_event->setTitle(result[1]);
				$sub_event->setEvent_id(result[2]);
				$sub_event->setLocation_id(result[3]);
				$sub_event->setBegin(result[4]);
				$sub_event->setEnd(result[5]);
				$sub_event->setEventDay_id(result[6]);
			} else {
				$sub_event = false
			}
			return $sub_event;
		}// end function

		public function updateSub_event($sub_event) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO sub_event VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteSub_event($id) {
			global $con;
			$sql = 'DELETE FROM sub_event WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listSub_event() {
			global $con;
			$sql = 'SELECT * FROM sub_event';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$sub_events = array();
				while($result = mysqli_fetch_array($results)) {
					$sub_event = new Sub_event();
					$sub_event->setId(result[0]);
					$sub_event->setTitle(result[1]);
					$sub_event->setEvent(readEvent(result[2]));
					$sub_event->setLocation(readLocation(result[3]));
					$sub_event->setBegin(result[4]);
					$sub_event->setEnd(result[5]);
					$sub_event->setEventDay(readEventDay(result[6]));
					$sub_events[] = $sub_event;
				}// end while
			} else {
				$sub_event = false
			}
			return $sub_event;
		}// end function

		// task // --------------------

		public function createTask($task) {
			global $con;
			$fieldsString = csvObject($task);
			$valuesString = csvString($task);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readTask($id) {
			global $con;
			$sql = 'SELECT * FROM task WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$task = new Task();
				$task->setId(result[0]);
				$task->setTitle(result[1]);
			} else {
				$task = false
			}
			return $task;
		}// end function

		public function updateTask($task) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO task VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteTask($id) {
			global $con;
			$sql = 'DELETE FROM task WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listTask() {
			global $con;
			$sql = 'SELECT * FROM task';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$tasks = array();
				while($result = mysqli_fetch_array($results)) {
					$task = new Task();
					$task->setId(result[0]);
					$task->setTitle(result[1]);
					$tasks[] = $task;
				}// end while
			} else {
				$task = false
			}
			return $task;
		}// end function

		// vendor // --------------------

		public function createVendor($vendor) {
			global $con;
			$fieldsString = csvObject($vendor);
			$valuesString = csvString($vendor);
			$sql = 'INSERT INTO ' . $tableTitle . '(' . $fieldsString . ') VALUES (' . $valuesString . ')';
			$this->open();
			$result = mysqli_query($con, $sql);
			$id = ($result) ? mysqli_insert_id() : $result;
			$this->close();
			return $id;
		}// end function

		public function readVendor($id) {
			global $con;
			$sql = 'SELECT * FROM vendor WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$vendor = new Vendor();
				$vendor->setId(result[0]);
				$vendor->setBusiness_id(result[1]);
				$vendor->setEvent_id(result[2]);
				$vendor->setService(result[3]);
				$vendor->setDescription(result[4]);
				$vendor->setSubEvent_id(result[5]);
				$vendor->setCost(result[6]);
			} else {
				$vendor = false
			}
			return $vendor;
		}// end function

		public function updateVendor($vendor) {
			global $con;
			$fieldsString = csvString($fields);
			$sql = 'INSERT INTO vendor VALUES (' . $valueString . ')  WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function deleteVendor($id) {
			global $con;
			$sql = 'DELETE FROM vendor WHERE id = ' . $id;
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			return $result;
		}// end function

		public function listVendor() {
			global $con;
			$sql = 'SELECT * FROM vendor';
			$this->open();
			$result = mysqli_query($con, $sql);
			$this->close();
			if ($result) {
				$vendors = array();
				while($result = mysqli_fetch_array($results)) {
					$vendor = new Vendor();
					$vendor->setId(result[0]);
					$vendor->setBusiness(readBusiness(result[1]));
					$vendor->setEvent(readEvent(result[2]));
					$vendor->setService(result[3]);
					$vendor->setDescription(result[4]);
					$vendor->setSubEvent(readSubEvent(result[5]));
					$vendor->setCost(result[6]);
					$vendors[] = $vendor;
				}// end while
			} else {
				$vendor = false
			}
			return $vendor;
		}// end function

		
	}// end class
	
?>